<?php

namespace App\Event;

use App\Model\Server;
use App\Websocket\GlobalContext;
use Swoole\Server as SwooleServer;

class WebsocketConnectEvent
{
    public function __construct(SwooleServer $server)
    {
        $masterPid = $server->master_pid;
        $serverId = Server::insertGetId([
            'pid' => $masterPid,
        ]);

        GlobalContext::setContext($masterPid, $serverId);
    }
}